// app.js
App({
  globalData: {
    wxusername: '',
    wxuseravatar: '',
    commonIP: 'http://127.0.0.1:9527/front',
    wsIP: 'ws://127.0.0.1:9527/websocket',
    socketStatus: 'closed',
    chatList: []
  },

  onLaunch: function (event) {
    // 获取用户信息并存储到全局变量中
    this.globalData.wxusername = wx.getStorageSync('nickName')
    this.globalData.wxuseravatar = wx.getStorageSync('avatarUrl')
  },

  onShow: function (event) {
    // 获取用户信息并存储到全局变量中
    this.globalData.wxusername = wx.getStorageSync('nickName')
    this.globalData.wxuseravatar = wx.getStorageSync('avatarUrl')
  },

  countChineseCharacters: function (str) {
    const match = str.match(/[\u4e00-\u9fa5]/g);
    return match ? match.length : 0;
  }
})